package middleware

import (
	"fmt"
	"github.com/kataras/iris/v12"
	"golearning_iris/gt"
)

func MyMiddleware(ctx iris.Context) {
	//ctx.Application().Logger().Info("Runs Before %s", ctx.Path())
	gt.Logger.Sugar().Infof("Runs Beofre %s", ctx.Path())
	ctx.Next()
}


func Before(ctx iris.Context) {
	shareInformation := "this is a sharable information between handlers"

	requestPath := ctx.Path()
	fmt.Println("Before the mainHandler: " + requestPath)

	ctx.Values().Set("info", shareInformation)
	ctx.Next() // execute the next handler, in this case the main one.
}

func After(ctx iris.Context) {
	fmt.Println("After the mainHandler")
	ctx.Next()
}